package com.zatech.cgnci.project.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author EDY
 * @version 1.0
 * Create by 2024/12/18 17:40
 */
@Data
@ApiModel(value = "CgnciBusinessProjectSaveOrUpdateDTO")
public class CgnciBusinessProjectSaveOrUpdateDTO {

    @ApiModelProperty(value = "工作流类型,固定值:submit")
    private String flowTaskType;

    @ApiModelProperty(value = "任务流程id")
    @NotNull(message = "approvalInfoId cannot be null")
    private Long approvalInfoId;

    @ApiModelProperty(value = "基本信息")
    @Valid
    private CgnciBusinessProjectUpdateDTO businessProjectUpdateDTO;

    @ApiModelProperty(value = "直保信息")
    @Valid
    private CgnciDirectInsuranceProjectUpdateDTO directInsuranceDTO;

    @ApiModelProperty(value = "分入信息")
    @Valid
    private CgnciReinsuranceInfoProjectUpdateDTO divideInDTO;

    @ApiModelProperty(value = "超净自留处理方式")
    @Valid
    private List<CgnciUnderwritingPolicyProjectUpdateDTO> underwritingPolicyDTO;

    @ApiModelProperty(value = "合约分出信息")
    @Valid
    private List<CgnciReinsuranceInfoProjectUpdateDTO> hyDivideOutDTOList;

    @ApiModelProperty(value = "临分分出信息")
    @Valid
    private CgnciReinsuranceInfoProjectUpdateDTO lfDivideOutDTO;

    @ApiModelProperty(value = "文件list")
    private List<AccessoryDTO> accessoryDTOList;


    @Data
    public static class CgnciBusinessProjectUpdateDTO {

        @ApiModelProperty("业务ID")
        private Long projectId;

        @ApiModelProperty("业务名称")
        private String projectName;

        @ApiModelProperty("业务英文名称")
        private String projectNameEn;

        @ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;

        @ApiModelProperty("起期")
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
        private Date startDate;

        @ApiModelProperty("止期")
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
        private Date endDate;

        @ApiModelProperty("保险期限(天)")
        private Integer insuranceDays;

        @ApiModelProperty("业务年度")
        private String projectYear;

        @ApiModelProperty("业务年度范围")
        private String projectYears;

        @ApiModelProperty("分入日期")
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
        private Date entryDate;

        @ApiModelProperty("币种")
        private String currency;

        @ApiModelProperty("汇率约定方式(1-按数值，2-按日期),码表值:exchangeRateType")
        private String exchangeRateType;

        @ApiModelProperty("汇率")
        @DecimalMin(value = "0", message = "基本信息-汇率必须大于0")
        private BigDecimal exchangeRate;

        @ApiModelProperty("业务承接类型(1-临分分入,2-预约临分分入,3-合约分入),码表值:projectAcceptanceType")
        private String projectAcceptanceType;

        @ApiModelProperty("承保范围")
        private String coverageScope;

        @ApiModelProperty("PML")
        @DecimalMin(value = "0", message = "基本信息-pml必须大于0")
        private BigDecimal pml;

        @ApiModelProperty(value = "有无查勘报告(1-有；0-无),码表值:isHave")
        private String isSurveyReport;

        @ApiModelProperty("备注")
        private String remark;
    }

    @Data
    public static class CgnciDirectInsuranceProjectUpdateDTO {

        @ApiModelProperty("直保ID")
        private Long directId;

        @ApiModelProperty("直保项目")
        private String directItem;

        @ApiModelProperty("直保经纪人")
        private String broker;

        @ApiModelProperty("保费(不含税)")
        private BigDecimal premiumExclTax;

        @ApiModelProperty("保费(含税)")
        private BigDecimal premiumInclTax;

        @ApiModelProperty("直保被保险人")
        private String insuredInsurer;

        @ApiModelProperty("直保保险人")
        private String directInsurer;

        @ApiModelProperty("备注")
        private String remark;

        @ApiModelProperty("直保险种列表")
        @Valid
        private List<CgnciDirectInsuranceRiskProjectUpdateDTO> directRisks;
    }

    @Data
    public static class CgnciDirectInsuranceRiskProjectUpdateDTO {

        @ApiModelProperty("直保险种ID")
        private Long riskId;

        @ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;

        @ApiModelProperty("直保险种标的列表")
        @Valid
        private List<CgnciDirectInsuranceDetailProjectUpdateDTO> details;

    }

    @Data
    public static class CgnciDirectInsuranceDetailProjectUpdateDTO {

        @ApiModelProperty("明细ID")
        private Long detailId;

        @ApiModelProperty("rowKey")
        private String rowKey;

        /*@ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;*/

        @ApiModelProperty("保险标的")
        private String insuredObject;

        @ApiModelProperty("保险标的类型(1-在案;2-离案),码表值:onshoreOffshore")
        private String insuredType;

        @ApiModelProperty("保额/单次事故最大赔偿限额")
        @DecimalMin(value = "0", message = "直保信息-保额/单次事故最大赔偿限额必须大于0")
        private BigDecimal maxCompensation;

        @ApiModelProperty("保费(含税)")
        @DecimalMin(value = "0", message = "直保信息-保费(含税)必须大于0")
        private BigDecimal premiumInclTax;

        @ApiModelProperty("税率")
        @DecimalMin(value = "0", message = "直保信息-税率必须大于0")
        private BigDecimal taxRate;

        @ApiModelProperty("保费(不含税)")
        @DecimalMin(value = "0", message = "直保信息-保费(不含税)必须大于0")
        private BigDecimal premiumExclTax;

        @ApiModelProperty("免赔说明")
        private String deductibleDesc;

        @ApiModelProperty("离岸业务归属地")
        private String offshoreTerritory;

        @ApiModelProperty(value = "文件list")
        private List<AccessoryDTO> accessoryDTOList;

    }

    @Data
    public static class CgnciReinsuranceInfoProjectUpdateDTO {

        @ApiModelProperty("再保ID")
        private Long reinsuranceId;

        @ApiModelProperty("类型(1-分入,2-合约分出,3-临分分出),码表值:divideType")
        @NotBlank(message = "类型不能为空")
        private String reinsuranceType;

        @ApiModelProperty("方式(1-比例,2-非比例),码表值:proportionalMode")
        private String reinsuranceMethod;

        @ApiModelProperty("再保经纪人")
        private String broker;

        @ApiModelProperty("具体业务类型(1-成数,2-溢额,3-成数溢额混合,4-累计损失超赔,5-险位超赔,6-巨灾超赔),码表值:contractType")
        private String businessType;

        @ApiModelProperty("分出价格确认(1-按分入净保费,2-按再保人定价),码表值:priceConfirmationType")
        private String priceConfirmationType;

        @ApiModelProperty("价格确认方式说明")
        private String priceConfirmation;

        @ApiModelProperty("总再保手续费率")
        private BigDecimal totalBrokerCommissionRate;

        @ApiModelProperty("总再保经纪费")
        private BigDecimal totalBrokerFee;

        @ApiModelProperty("总手续费率")
        private BigDecimal totalCommissionRate;

        @ApiModelProperty("总手续费")
        private BigDecimal totalCommission;

        @ApiModelProperty("总毛保费")
        private BigDecimal totalGrossPremium;

        @ApiModelProperty("总净保费")
        private BigDecimal totalNetPremium;

        @ApiModelProperty("再保经纪费率")
        private BigDecimal brokerFeeRate;

        @ApiModelProperty("分保手续费率")
        private BigDecimal procedureRate;

        @ApiModelProperty("合约编号")
        private String contractNo;

        @ApiModelProperty("合约名称")
        private String contractName;

        @ApiModelProperty("累计赔偿限额(非比例)")
        private BigDecimal aggregateLimit;

        @ApiModelProperty("险种信息")
        @Valid
        private List<CgnciReinsuranceRiskProjectUpdateDTO> risks;
    }

    @Data
    public static class CgnciReinsuranceRiskProjectUpdateDTO {

        @ApiModelProperty("分入分出险种ID")
        private Long reinsuranceRiskId;

        @ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;

        /*@ApiModelProperty("保险标的名称")
        private String insuredObject;

        @ApiModelProperty("保险标的类型(1-在案;2-离案),码表值:onshoreOffshore")
        private String insuredType;

        @ApiModelProperty("离岸业务归属地")
        private String offshoreTerritory;*/

        @ApiModelProperty("险种标的列表")
        @Valid
        private List<CgnciReinsuranceRiskInsuredProjectUpdateDTO> riskInsureds;
    }

    @Data
    public static class CgnciReinsuranceRiskInsuredProjectUpdateDTO {

        @ApiModelProperty("分入分出险种标的ID")
        private Long riskInsuredId;

      /*  @ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;*/

        @ApiModelProperty("rowKey")
        private String rowKey;

        @ApiModelProperty("保险标的名称")
        private String insuredObject;

        @ApiModelProperty("保险标的类型(1-在案;2-离案),码表值:onshoreOffshore")
        private String insuredType;

        @ApiModelProperty("离岸业务归属地")
        private String offshoreTerritory;

        @ApiModelProperty("险种层信息")
        @Valid
        private List<CgnciReinsuranceRiskLayerProjectUpdateDTO> riskLayers;
    }

    @Data
    public static class CgnciReinsuranceRiskLayerProjectUpdateDTO {

        @ApiModelProperty("层ID")
        private Long layerId;

        @ApiModelProperty("唯一键")
        private String layerRowKey;

        @ApiModelProperty("层名称")
        private String layerName;

        @ApiModelProperty("层序号")
        private Integer layerSequence;

        @ApiModelProperty("保单限额")
        @DecimalMin(value = "0", message = "保单限额必须大于0")
        private BigDecimal policyLimit;

        @ApiModelProperty("承接比例")
        @DecimalMin(value = "0", message = "承接比例必须大于0")
        private BigDecimal shareRatio;

        @ApiModelProperty("承接限额")
        @DecimalMin(value = "0", message = "承接限额必须大于0")
        private BigDecimal shareLimit;

        @ApiModelProperty("起赔点")
        @DecimalMin(value = "0", message = "起赔点必须大于0")
        private BigDecimal deductible;

        @ApiModelProperty("赔偿限额")
        @DecimalMin(value = "0", message = "赔偿限额必须大于0")
        private BigDecimal compensationLimit;

        @ApiModelProperty("层占比")
        @DecimalMin(value = "0", message = "层占比必须大于0")
        private BigDecimal layerPremiumRatio;

        @ApiModelProperty("自留额")
        //@DecimalMin(value = "0", message = "自留额必须大于0")
        private BigDecimal retentionAmount;

        @ApiModelProperty("分入/分出毛保费")
        @DecimalMin(value = "0", message = "分入/分出毛保费必须大于0")
        private BigDecimal grossPremium;

        @ApiModelProperty("分入/分出手续费")
        @DecimalMin(value = "0", message = "分入/分出手续费必须大于0")
        private BigDecimal commission;

        @ApiModelProperty("分入/分出净保费")
        @DecimalMin(value = "0", message = "分入/分出净保费必须大于0")
        private BigDecimal netPremium;

        @ApiModelProperty("分入/分出再保经纪费")
        @DecimalMin(value = "0", message = "分入/分出再保经纪费必须大于0")
        private BigDecimal brokerFee;

        @ApiModelProperty("免赔说明")
        private String deductibleDesc;

        @ApiModelProperty("分入限额")
        @DecimalMin(value = "0", message = "分入限额必须大于0")
        private BigDecimal engagedLimit;

        @ApiModelProperty("分出比例")
        @DecimalMin(value = "0", message = "分出比例必须大于0")
        private BigDecimal cededRatio;

        @ApiModelProperty("分出限额")
        @DecimalMin(value = "0", message = "分出限额必须大于0")
        private BigDecimal cededLimit;

        @ApiModelProperty("预估保费")
        @DecimalMin(value = "0", message = "预估保费必须大于0")
        private BigDecimal estimatedPremium;

        @ApiModelProperty("单次事故最高赔偿限额")
        @DecimalMin(value = "0", message = "单次事故最高赔偿限额必须大于0")
        private BigDecimal singleAccidentLimit;

        @ApiModelProperty("费率")
        @DecimalMin(value = "0", message = "费率必须大于0")
        private BigDecimal rate;

        @ApiModelProperty("预估GNPI")
        @DecimalMin(value = "0", message = "预估GNPI必须大于0")
        private BigDecimal estimateGnpi;

        @ApiModelProperty("再保人定价")
        @DecimalMin(value = "0", message = "再保人定价必须大于0")
        private BigDecimal reinsurerPricing;

        @ApiModelProperty("线数")
        @Min(value = 0, message = "线数大于0")
        private Integer layerLines;

        @ApiModelProperty(value = "文件list")
        private List<AccessoryDTO> accessoryDTOList;

    }

    @Data
    public static class CgnciUnderwritingPolicyProjectUpdateDTO {

        @ApiModelProperty("政策ID")
        private Long policyId;

        @ApiModelProperty("险类")
        private String riskClass;

        @ApiModelProperty("险类代码")
        private String riskClassCode;

        @ApiModelProperty("险种")
        private String riskSubType;

        @ApiModelProperty("险种代码")
        private String riskSubTypeCode;

        @ApiModelProperty("是否涉核(1-是，0-否),码表值:isYes")
        private String isExamine;

        @ApiModelProperty("最大自留额(人民币)")
        @DecimalMin(value = "0", message = "最大自留额(人民币)必须大于0")
        private BigDecimal insuredAmountRmb;

        @ApiModelProperty("最大自留额(美元)")
        @DecimalMin(value = "0", message = "最大自留额(美元)必须大于0")
        private BigDecimal insuredAmountDollar;

        @ApiModelProperty("自留额")
        //@DecimalMin(value = "0", message = "自留额必须大于0")
        private BigDecimal retentionAmount;

        @ApiModelProperty("自留额币种")
        private String retentionCurrency;

        @ApiModelProperty("自留额汇率")
        private BigDecimal retentionRate;

        @ApiModelProperty("是否超最大净自留限额(1-是，0-否),码表值:isYes")
        private String exceedLimit;

        @ApiModelProperty("再保分出安排(1-临分分出,2-合约分出,3-预约临分分出),码表值:reinsuranceArrangement")
        private String reinsuranceArrangement;
    }


    @Data
    public static class AccessoryDTO {

        @NotNull(message = "文件id不能为空")
        @ApiModelProperty(value = "文件id")
        private Long accId;

        @ApiModelProperty(value = "业务编号(关联业务表主键id)", hidden = true)
        private Long businessId;

        @ApiModelProperty(value = "业务号", hidden = true)
        private String businessNo;

        @ApiModelProperty(value = "业务类型（根据业务自定义业务类型进行区分）", hidden = true)
        private String businessType;

        @ApiModelProperty(value = "文件类型", hidden = true)
        private String accType;

        @ApiModelProperty(value = "上传节点", hidden = true)
        private String uploadNode;

        @ApiModelProperty(value = "附件云编号", hidden = true)
        private String fileId;

        @ApiModelProperty(value = "附件名称", hidden = true)
        private String fileName;

        @ApiModelProperty(value = "附件类型", hidden = true)
        private String fileType;

        @ApiModelProperty(value = "有效起期", hidden = true)
        private Date startTime;

        @ApiModelProperty(value = "有效止期", hidden = true)
        private Date endTime;

        @ApiModelProperty(value = "上传时间", hidden = true)
        private Date uploadTime;

        @ApiModelProperty(value = "状态（0：失败，1：成功）", hidden = true)
        private String status;

        @ApiModelProperty(value = "操作结果描述", hidden = true)
        private String msg;

        @ApiModelProperty(value = "删除标志位（0：未删除，1：已删除）", hidden = true)
        private Integer dr;

    }

}
